{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Area under 1-D and 2-D curves, various methods\n", "\n", "**Randall Romero Aguilar, PhD**\n", "\n", "This demo is based on the original Matlab demo accompanying the Computational Economics and Finance 2001 textbook by Mario Miranda and Paul Fackler.\n", "\n", "Original (Matlab) CompEcon file: **demqua03.m**\n", "\n", "Running this file requires the Python version of CompEcon. This can be installed with pip by running\n", "\n", " !pip install compecon --upgrade\n", "\n", "Last updated: 2022-Oct-23\n", "
\n", " | \n", " | Trapezoid rule | \n", "Simpson's rule | \n", "Gauss-Legendre | \n", "
---|---|---|---|---|
$\\int_{-1}^1e^{-x}dx$ | \n", "5 | \n", "-1.683044 | \n", "-3.472173 | \n", "-9.454795 | \n", "
11 | \n", "-2.477411 | \n", "-5.053217 | \n", "-14.273349 | \n", "|
21 | \n", "-3.079254 | \n", "-6.255789 | \n", "-14.675836 | \n", "|
31 | \n", "-3.431396 | \n", "-6.959867 | \n", "-15.653560 | \n", "|
$\\int_{-1}^1\\sqrt{|x|}dx$ | \n", "5 | \n", "-1.023788 | \n", "-1.367611 | \n", "-0.870112 | \n", "
11 | \n", "-1.595301 | \n", "-1.347900 | \n", "-1.351241 | \n", "|
21 | \n", "-2.034517 | \n", "-2.414470 | \n", "-1.758970 | \n", "|
31 | \n", "-2.293296 | \n", "-2.063539 | \n", "-2.007803 | \n", "